﻿Namespace Isyeri.Bordro
	Module Functions

		Function TumEmekliCalisanlar(ByVal Process As Token, ByVal isyerino As String) As Recordset
			Q("select kimlik, ymbastar from yaslılık..yasmaasbil")
			Q("where odeyerkod < 900 and kimlik in (select distinct kimlik from sigc where isyerino = @isyerino)")
			Q("and hturu in (select hturu from yaslılık..yashesaptur where myo = 'Y')")
			Return Process.OpenSQL("*", isyerino)
		End Function

		Function CalismaIzni(ByVal Process As Token, isyerino As String) As Recordset
			Return Process.OpenSQL("select * from scalisma where isyerino = @isyerino", isyerino)
		End Function

		Function Rapor(ByVal Process As Token, isyerino As String, bordrotar As Date) As Recordset
			Q("select * from (")
			Q("select 'h' as tur,repsube,sno,kimlik,dosyano,histbastar as bastar,histsontar as bittar from ssd..shasrapor union all")
			Q("select 'i' as tur,repsube,sno,kimlik,dosyano,histbastar as bastar,histsontar as bittar from ssd..siskrapor union all")
			Q("select 'a' as tur,repsube,sno,kimlik,dosyano,sanabastar as bastar,sanasontar as bittar from ssd..sagecici) t")
			Q("where sno in (select sno from sigc where isyerino = @isyerino)")
			Q("and bittar >= @tarih1 and bastar <= @tarih2")
			Return Process.OpenSQL("*", isyerino, bordrotar, bordrotar.AddMonths(1).AddDays(-1))
		End Function

		Function Yatirim(ByVal Process As Token, isyerino As String, bordrotar As Date) As Recordset
			Q("select sno,kimlik,sum(pogs) as pogs from")
			Q("(select sno,kimlik,pogs from shesk where isyerino = @isyerino and bordrotar = @bordrotar union all")
			Q("select sno,kimlik,pogs from sheskp where isyerino = @isyerino and bordrotar = @bordrotar) t")
			Q("group by sno,kimlik")
			Return Process.OpenSQL("*", isyerino, bordrotar)
		End Function

	End Module
End Namespace
